{% extends "base-left.html" %}
{% load staticfiles %}

{% block css %}
<link rel="stylesheet" href="{% static 'js/plugins/layer/skin/layer.css' %}">
{% endblock %}

{% block content %}

<!-- Content Header (Page header) -->
<section class="content-header margin-bottom">
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i>办公平台</a></li>
    <li class="active"><a href="{{ menu.parent.parent.url }}">{{ menu.parent.parent.title }}</a></li>
    <li class="active"><a href="{{ menu.url }}">{{ menu.title }}</a></li>
  </ol>
</section>
    <!-- Main content -->
  <section class="content">

     <div class="col-md-8">
          <!-- Horizontal Form -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">系统设置</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" id="addForm" method="post">
            {% csrf_token %}
              <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-2 control-label" >登录标题</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="loginTitle" placeholder="自定义登录页面系统显示名称" value="{{ system_setup.loginTitle|default_if_none:'' }}">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" >系统标题</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="mainTitle" placeholder="自定义系统主页面显示名称" value="{{ system_setup.mainTitle|default_if_none:'' }}">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" >浏览器标题</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="headTitle" placeholder="自定义浏览器头部标题" value="{{ system_setup.headTitle|default_if_none:'' }}">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" >底部版权信息</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="copyright" placeholder="自定义底部版权信息" value="{{ system_setup.copyright|default_if_none:'' }}">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" >系统URL</label>

                  <div class="col-sm-10">
                    <input type="text" class="form-control" name="url" placeholder="系统对外发布的URL" value="{{ system_setup.url|default_if_none:'' }}">
                  </div>
                </div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer ">
			    <div class="row span7 text-center ">
                  <button type="button" id="btnCancel" class="btn btn-default margin-right " >重置</button>
                  <button type="button" id="btnSave" class="btn btn-info margin-right " >保存</button>
			    </div>
		      </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
     </div>

  </section>

    <!-- /.content -->

{% endblock %}

{% block javascripts %}
  <script src="{% static 'js/plugins/layer/layer.js' %}"></script>
  <script type="text/javascript">
	$(function() {
        $('#SYSTEM-TOOLS').addClass('active');
		$('#SYSTEM-TOOLS-SYSTEM_SETUP').addClass('active');
	});
  </script>

  <script type="text/javascript">

	$("#btnSave").click(function(){
		var data = $("#addForm").serialize();
		$.ajax({
			type: $("#addForm").attr('method'),
			url : "{% url 'system-tools:system_setup' %}",
			data : data,
			cache: false,
			success : function(msg) {
				if (msg.result){
					layer.alert('数据保存成功！', {icon: 1},function(index){
					    parent.layer.closeAll(); //关闭所有弹窗
                    });
				}else{
					layer.alert('数据保存失败', {icon: 5});
                    //$('errorMessage').html(msg.message)
				}
				return ;
			}
		});
	});


	/*点取消刷新新页面*/
    $("#btnCancel").click(function () {
	    window.location.reload();

    });

  </script>

{% endblock %}